package com.one.odf.controller;

import com.one.odf.model.BodyType;
import lombok.extern.log4j.Log4j2;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import org.json.XML;

/**
 * @description: 消息接收
 * @author: zero
 * @date: 2020/1/8
 */
@RestController
@Log4j2
public class MsgController {



    @PostMapping(value = "msg",consumes = MediaType.APPLICATION_XML_VALUE )
    public String sendMsg(@RequestBody BodyType odfBody) throws Exception {
        log.info("===========>请求入参:{}",odfBody);
        log.info("===========xsd,xml校验开始==========");
        //XmlUtils.validate(new FileInputStream("F:\\WORKSPACE\\ONESPORTS\\odf\\src\\main\\resources\\odf\\odf2.xsd"),new ByteArrayInputStream(XmlUtils.convertToXml(odfBody).getBytes("UTF-8")));
        //XmlUtils.validate(new FileInputStream("F:\\WORKSPACE\\ONESPORTS\\odf\\src\\main\\resources\\odf\\odf2.xsd"),new FileInputStream("F:\\WORKSPACE\\ONESPORTS\\odf\\src\\main\\resources\\odf\\odf2.xml"));
        log.info("===========xsd,xml校验结束==========");
        XML.toJSONObject("");
        return "ok";
    }
}
